import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'upgrade_platform_interface.dart';

/// An implementation of [UpgradePlatform] that uses method channels.
class MethodChannelUpgrade extends UpgradePlatform {
  /// The method channel used to interact with the native platform.
  @visibleForTesting
  final methodChannel = const MethodChannel('upgrade');

  @override
  Future<String?> getPlatformVersion() async {
    final version = await methodChannel.invokeMethod<String>('getPlatformVersion');
    return version;
  }

  @override
  Future<bool?> install(String path) async {
    final result = await methodChannel.invokeMethod<bool>('install', path);
    return result;
  }

  @override
  Future<Map?> getVersionInfo() async {
    final info = await methodChannel.invokeMethod<Map>('getVersionInfo');
    return info;
  }

}
